    #!/bin/perl
package data;
    use strict;
    use DBI;
    use utf8;

	#这一句，可以避免出现由于变量只使用一次出现的 use only once 警告 
	no warnings('once');  
	#包含配置文件
	require '../../conf/config.pl';
    
    our %db_conf = %conf::db_conf ; 
    my $db_host = $db_conf{'db_host'};
    my $db_user = $db_conf{'db_user'};
    my $db_pwd = $db_conf{'db_pwd'};

    # Connect to target DB
    my $dbh = DBI->connect("$db_host","$db_user","$db_pwd");

    my $to="";
    my $i=0;
	
    my $contents="";
    $contents="<style type='text/css'>div{border:0px solid #CCC;} div.h{float:left;width:80px;margin:auto;overflow-x:hidden;} body {background-color:#D5D5D5} table.header {font-size:13pt;background-color:#F3F3F3; width:80%; height:8;border-top: 2px solid #FFFFFF; border-left: 2px solid #FFFFFF; border-right: 2px solid #8995FA; border-bottom: 2px solid #8995FA; } table.rate {font-size:16pt;background-color:#F3F3F3;width:80% } table.maincontent {font-size:11pt;background-color:#F3F3F3;width:80%;border-collapse:collapse;  } table.maincontent td{border:solid #000 1px;} table.content {font-size:10pt;background-color:#F3F3F3;width:80% }  table.contentG {font-size:11pt;background-color:#FFCCFF;width:80% } table.contentN {font-size:10pt;background-color:#CCCCCC;width:80% } table.footer {font-size:10pt; background-color:#669900;width:80%} P {text-align:left;color:red} .A {width:100%;height:10;text-align:center} .B {text-align:center } .C {color:#AC0000} .D{color:#339933} .E {width:150} .F {font-weight:bold,color:#FF0000} a:visited{color:blue;text-decoration:none} a:link{text-decoration:none} .H {font-size:11pt;background-color:#669900;}</style> <html><body><table class=header align='center'><tr><td class=A>Reports </td></tr></table>";
 
    $contents.="<table class=content align='center'> <tr> <td align=center><table width=80%>";

    # 计分平衡卡
    my $sqr = $dbh->prepare("sp_columns jfphk_2_4_10");
    $sqr->execute();
$contents.="  <tr>";
while (my @data=$sqr->fetchrow_array()){
$contents.="  <th class=B> $data[3] </th>";
}
$contents.="  </tr>";
    $sqr = $dbh->prepare("select * from dbo.jfphk_2_4_10");
    $sqr->execute();

while (my @data=$sqr->fetchrow_array()){
$contents.="  <tr><td class=B> $data[0] </td><td class=B> <div align=left>$data[1] </div></td><td><div align=right> $data[2] </div></td><td><div align=right> $data[3] </div></td><td><div align=right> $data[4] </div></td><td><div align=right> $data[5] </div></td></tr>";
}

    $contents.="</table></td></tr></table>";
    $contents.="<table class=content align='center'> <tr> <td align=center><table width=80%>";

    #财务费用统计表
    $sqr = $dbh->prepare("sp_columns cwfytj_2_2");
    $sqr->execute();
    $contents.="  <tr>";
    while (my @data=$sqr->fetchrow_array()){
    $contents.="  <th class=B> $data[3] </th>";
    $i=$i+1;
    }
    $contents.="  </tr>";

    $sqr = $dbh->prepare("select * from dbo.cwfytj_2_2");
    $sqr->execute();

    while (my @data=$sqr->fetchrow_array()){
    $contents.="  <tr>";
    for (my $count = 0; $count <= $i; $count++) {
 	$contents.="<td> $data[$count] </td>";
    }
    $contents.="  </tr>";
    #$contents.="  <tr><td class=B> $data[0] </td><td class=B> <div align=left>$data[1] </div></td><td><div align=right> $data[2] </div></td><td><div align=right> $data[3] </div></td><td><div align=right> $data[4] </div></td><td><div align=right> $data[5] </div></td></tr>";
    }

 #   while(my $ref = $sqr->fetchrow_hashref()) {
 #	$contents.="<tr><td class=B>$ref->{'name'}</td><td class=B>$ref->{'description'}</td></tr>";
 #   }

    $contents.="</table></td></tr></table>";

    $dbh->disconnect();

    

    my $footer = <<"___FOOT___";
<table class=content align='center'>
<tr></tr><tr></tr><tr></tr><tr><td class=D> 和黄商贸办公网站入口 : <a href="my.hwccl.com">my.hwccl.com</a></td></tr>
<tr></tr><tr><td class=D>计算机/网络故障处理方法： 1.联系报障中心：<a href="mailto:it\@hwccl.com">it\@hwccl.com</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.IMO-在搜索栏输入： it </td></tr>
<tr><td> </td></tr><tr></tr><tr></tr>

<tr><td class=D>
IT技术服务工程师：<br>
Suan: 020-86266855/6833-291<br>
Landy: 020-86266855/6833-324<br>
Marco:020-86266855/6833-326<br>
Homy: 020-86266855/6833-235
</td></tr></table>
<table class=footer align='center'><tr><td class=B>版权所有：<font color=#FF0000>和记黄埔（中国）商贸有限公司</font></td></tr></table></body></html>
___FOOT___

    #$contents.=$footer;
    $to='Meanson <meansonw@hwccl.com>';
    

our %db = (
html => $contents,
to => $to
);
